<?php
/**
 * model-版块管理
 * [ranknow bbs!] (C)2009-2015 ranknow.cn.
 *
 * @author liwei
 * @This is NOT a freeware, use is subject to license terms
 * @rcsfile $RCSfile: mdl_forum,v $
 * @revision $Revision: 0.1 $
 * @date $Date: 2009/12/29 03:40:17 $
 */
function get_forum_list( $offset = 0, $pageSize = 10 ) {
    $data = array();
    $sql = "select fid,name,description from bbs_forums";
    $data = dbPageQuery( $sql, $offset, $pageSize );
    return $data['data'];
}

function delete_forum_by_id( $id = 0 ) {
    if ( $id > 0 ) {
        $sql = sqlMakeDelById( 'bbs_forums', 'fid', $id );
        return dbExecute( $sql );
    } else {
        return false;
    }
}

function get_forum_by_id( $fid = 0 ) {
    $forum = array('fid'=>'0','name'=>'','description'=>'');
    if ( $fid > 0 ) {
        $sql = "SELECT fid,name,description FROM bbs_forums WHERE fid='$fid'";
        $forum = dbGetRow( $sql );
    }
    return $forum;
}

function add_forum( $data = '' ) {
    if ( !is_array( $data ) || count( $data ) == 0 ) {
        return false;
    } else {
        $sql = sqlMakeInsert( 'bbs_forums', $data );
        return dbExecute( $sql );
    }
}

function update_forum( $data = '' ) {
    if ( !is_array( $data ) || count( $data ) == 0 ) {
        return false;
    } else {
        $sql = sqlMakeReplace( 'bbs_forums', $data );
        return dbExecute( $sql );
    }
}
?>